﻿using ArcGIS.Core.CIM;
using ArcGIS.Core.Data;
using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Catalog;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Editing;
using ArcGIS.Desktop.Extensions;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Layouts;
using ArcGIS.Desktop.Mapping;
using CCTool.Scripts.Manager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace CCTool.Scripts.UI.ProButton
{
    internal class VgExcelXZTZB : Button
    {
        // 定义一个进度框
        private ProcessWindow processwindow = null;
        string tool_name = "1、生成现状指标表";

        protected override async void OnClick()
        {
            try
            {
                // 打开进度框
                ProcessWindow pw = UITool.OpenProcessWindow(processwindow, tool_name);
                pw.AddMessageTitle(tool_name);
                pw.AddMessageStart("获取村庄名称");

                await QueuedTask.Run(() =>
                {
                    // 获取村庄名称列表
                    List<string> village_names = VG.GetVillageNames();
                    // 处理每个村庄
                    foreach (var village_name in village_names)
                    {
                        pw.AddMessageMiddle(10, "【" + village_name + "】\r");
                        // 创建文件目录
                        VG.CreateJPGFolder(village_name);
                        // 创建现状指标表
                        VG.CreateExcelXZTZB(village_name, pw, true);
                    }
                });
                pw.AddMessageEnd();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message + ee.StackTrace);
                return;
            }
        }
    }
}
